using System.Runtime.CompilerServices;
using DA.Client.Base.Abstractions.Navigation;
using DA.Client.Base.Models.Navigation;

namespace DA.Client.Base.Helpers;

/// <summary>
/// 参数异常助手
/// </summary>
public class ArgumentExceptionHelper
{
    public static void ThrowIfNullEmpty(string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
    {
        if (string.IsNullOrEmpty(argument))
        {
            throw new ArgumentNullException(paramName);
        }
    }

    public static void ThrowIfOutRange(bool argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
    {
        if (argument)
        {
            throw new ArgumentOutOfRangeException(paramName);
        }
    }

    public static void ThrowIfNavigationCommandNull(INavigationCommand? command, [CallerArgumentExpression(nameof(command))] string? paramName = null)
    {
        if (command is null)
        {
            throw new NavigationCommandNotFoundException(paramName);
        }
    }
}